//
//  RTSArea2d.m
//  RecipeCollection02
//
//  Created by Louis CHU on 23/02/12.
//  Copyright (c) 2012 Nathan Burba. All rights reserved.
//

#import "RTSArea2d.h"
#include "b2World.h"

@interface RTSArea2d ()
{
    b2World * _world;
    
    
}

@property (nonatomic, retain) CCNode * gameNode_;

@end

@implementation RTSArea2d

@synthesize gameNode_;

- (void) dealloc
{
    delete _world;
    _world = NULL;
    
    self.gameNode_ = nil;
    
    [super dealloc];
}

- (void) step: (ccTime) dt
{
    int32 velocityIterations = 8;
	int32 positionIterations = 3;
	
	_world->Step(dt, velocityIterations, positionIterations);
}


- (CCLayer *) runRecipe
{
    [super runRecipe];
    self.gameNode_ = [[CCNode alloc] init];
	self.gameNode_.position = ccp(0,0);
	[self addChild:self.gameNode_ z:1];
    
    b2Vec2 gravity;
    gravity.Set(0, 0);
    
    _world = new b2World(gravity, YES);
    _world->SetContinuousPhysics(YES);
    
    
    
    
    return self;
}

@end
